package com.recruit.service;

import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.common.util.AJAXResultMessage;
import com.recruit.dao.RecruitRepository;
import com.recruit.entity.Recruit;

@Service
@Transactional
public class RecruitService implements IRecruitService {

	@Autowired
	private RecruitRepository recruitRepository;
	@Override
	public AJAXResultMessage saveOrUpdate(Recruit recruit) {
		recruitRepository.save(recruit);
		
		return new AJAXResultMessage(true,"操作成功");
	}

	@Override
	public void delete(Recruit recruit) {
		recruitRepository.delete(recruit);

	}

	@Override
	public Recruit findOne(Long id) {
		return recruitRepository.findOne(id);
	}

	@Override
	public List<Recruit> findAll() {
		return (List<Recruit>) recruitRepository.findAll();
	}

	@Override
	public void delete(List<Long> ids) {
		List<Recruit> recruitList=(List<Recruit>) recruitRepository.findAll(ids);
		recruitRepository.delete(recruitList);

	}

	@Override
	public Page<Recruit> findAll(Specification<Recruit> spec, Pageable pageable) {
		return recruitRepository.findAll(spec, pageable);
	}

}
